Title: SQL BT (By-BKK) / 08 Nulls
Tags: Obsidian_to_Anki

Q: What is a NULL value in SQL?
A: A marker indicating missing or unknown data

Q: True or False: You should always avoid NULL values in databases if possible.
A: True

Q: What is an alternative to using NULL values in databases?
A: Default values like 0 or empty strings

Q: Why can using default values instead of NULL sometimes be a problem?
A: Defaults can skew analysis, like averaging numbers

Q: How do you check for NULL values in a SQL query?
A: Use IS NULL in the WHERE clause

Q: How do you find rows where a column is NOT NULL in SQL?
A: Use IS NOT NULL in the WHERE clause

Q: When are NULL values often unavoidable?
A: When joining tables with asymmetric data

Q: Reverse card: A marker for missing or unknown data
A: What does NULL represent in SQL?

Q: Reverse card: IS NULL and IS NOT NULL
A: Which SQL expressions check for missing data in a column?

Q: Reverse card: True
A: Is it good practice to minimize NULL values in databases?

Q: Reverse card: Defaults can skew analysis
A: Why might using 0 or empty string instead of NULL be misleading?

Q: Write a query to find employees with no assigned building.
A: SELECT name, role FROM employees WHERE building IS NULL;

Q: Write a query to find building names with no employees.
A: SELECT building_name FROM buildings LEFT JOIN employees ON buildings.building_name = employees.building WHERE employees.name IS NULL;